package com.yonyou.pmclouds.comprehensiveacceptance.process;

import com.yonyou.pmclouds.basecom.bp.processor.SingleProcessor;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.comprehensiveacceptance.entity.ComprehensiveAcceptanceVO;
import com.yonyou.pmclouds.inspectitem.entity.InspectItemVO;
import com.yonyou.pmclouds.inspectitem.rmiitf.InspectItemService;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class ComprehensiveAcceptanceAfterInsertFillInspectItemInfoProcess implements SingleProcessor<ComprehensiveAcceptanceVO>{
    @Autowired
    private InspectItemService itemService;
    @Override
    public void process(ComprehensiveAcceptanceVO vo, ComprehensiveAcceptanceVO orig) throws BusinessException {
    	InspectItemVO[] itemVOs = vo.getInspectitems();
        if(ArrayUtils.isEmpty(itemVOs)) {
           return;
        }
        String pkComprehensiveAcceptance = vo.getPkComprehensiveAcceptance();
        for (InspectItemVO inspectItemVO : itemVOs) {
        	inspectItemVO.setPk_bill(pkComprehensiveAcceptance);
        	inspectItemVO.setPk_project(vo.getPkProject());
        	inspectItemVO.setPosition(vo.getPosition());
            inspectItemVO.setLatitude(vo.getLatitude());
            inspectItemVO.setLongitude(vo.getLongitude());
            inspectItemVO.setPk_tenant(vo.getPkTenant());
        }
        // 添加检查项
        itemService.add(itemVOs, vo);
    }

}
